/* eslint-disable no-undef */
/* eslint-disable eqeqeq */
/* eslint-disable no-prototype-builtins */
/* eslint-disable no-empty */
layui.define(['layer'], function(f) {
  var $ = layui.jquery;
  var layuiLayer = layui.layer;
  var layuiCache = layui.cache;
  var CLASS_BODY = '.layui-layout-admin>.layui-body';
  var CLASS_TAB = CLASS_BODY + '>.layui-tab';
  var CLASS_SIDE_SCROLL = '.layui-layout-admin>.layui-side>.layui-side-scroll';
  var CLASS_HEAD = '.layui-layout-admin>.layui-header';
  var CLASS_SIDE_NAV = 'admin-side-nav';
  var admin = {
    version  : '3.1.8',
    layerData: {}
  };
  admin.flexible = function(i) {
    if (window !== top && !admin.isTop() && top.layui && top.layui.admin) {
      return top.layui.admin.flexible(i);
    }
    var q = $('.layui-layout-admin');
    var p = q.hasClass('admin-nav-mini');
    if (i === undefined) {
      i = p;
    }
    if (p === i) {
      if (window.sideFlexTimer) {
        clearTimeout(window.sideFlexTimer);
      }
      q.addClass('admin-side-flexible');
      window.sideFlexTimer = setTimeout(function() {
        q.removeClass('admin-side-flexible');
      }, 600);
      if (i) {
        admin.hideTableScrollBar();
        q.removeClass('admin-nav-mini');
      } else {
        q.addClass('admin-nav-mini');
      }
      layui.event.call(this, 'admin', 'flexible({*})', {
        expand: i
      });
    }
  };
  admin.activeNav = function(p) {
    if (window !== top && !admin.isTop() && top.layui && top.layui.admin) {
      return top.layui.admin.activeNav(p);
    }
    if (!p) {
      return console.warn('active url is null');
    }
    $(CLASS_SIDE_SCROLL + '>.layui-nav .layui-nav-item .layui-nav-child dd.layui-this').removeClass('layui-this');
    $(CLASS_SIDE_SCROLL + '>.layui-nav .layui-nav-item.layui-this').removeClass('layui-this');
    var s = $(CLASS_SIDE_SCROLL + '>.layui-nav a[lay-href="' + p + '"]');
    if (s.length === 0) {
      return console.warn(p + ' not found');
    }
    var r = $('.layui-layout-admin').hasClass('admin-nav-mini');
    if ($(CLASS_SIDE_SCROLL + '>.layui-nav').attr('lay-shrink') === '_all') {
      var i = s.parent('dd').parents('.layui-nav-child');
      if (!r) {
        $(CLASS_SIDE_SCROLL + '>.layui-nav .layui-nav-itemed>.layui-nav-child').not(i).css('display', 'block').slideUp('fast', function() {
          $(this).css('display', '');
        });
      }
      $(CLASS_SIDE_SCROLL + '>.layui-nav .layui-nav-itemed').not(i.parent()).removeClass('layui-nav-itemed');
    }
    s.parent().addClass('layui-this');
    var t = s.parent('dd').parents('.layui-nav-child').parent();
    if (!r) {
      var u = t.not('.layui-nav-itemed').children('.layui-nav-child');
      u.slideDown('fast', function() {
        if ($(this).is(u.last())) {
          u.css('display', '');
          var v = s.offset().top + s.outerHeight() + 30 - admin.getPageHeight();
          var w = 50 + 65 - s.offset().top;
          if (v > 0) {
            $(CLASS_SIDE_SCROLL).animate({
              'scrollTop': $(CLASS_SIDE_SCROLL).scrollTop() + v
            }, 300);
          } else {
            if (w > 0) {
              $(CLASS_SIDE_SCROLL).animate({
                'scrollTop': $(CLASS_SIDE_SCROLL).scrollTop() - w
              }, 300);
            }
          }
        }
      });
    }
    t.addClass('layui-nav-itemed');
    $('ul[lay-filter="' + CLASS_SIDE_NAV + '"]').addClass('layui-hide');
    var q = s.parents('.layui-nav');
    q.removeClass('layui-hide');
    $(CLASS_HEAD + '>.layui-nav>.layui-nav-item').removeClass('layui-this');
    $(CLASS_HEAD + '>.layui-nav>.layui-nav-item>a[nav-bind="' + q.attr('nav-id') + '"]').parent().addClass('layui-this');
  };
  admin.popupRight = function(i) {
    i.anim = -1;
    i.offset = 'r';
    i.move = false;
    i.fixed = true;
    if (i.area === undefined) {
      i.area = '336px';
    }
    if (i.title === undefined) {
      i.title = false;
    }
    if (i.closeBtn === undefined) {
      i.closeBtn = false;
    }
    if (i.shadeClose === undefined) {
      i.shadeClose = true;
    }
    if (i.skin === undefined) {
      i.skin = 'layui-anim layui-anim-rl layui-layer-adminRight';
    }
    return admin.open(i);
  };
  admin.open = function(r) {
    if (r.content && r.type === 2) {
      r.url = undefined;
    }
    if (r.url && (r.type === 2 || r.type === undefined)) {
      r.type = 1;
    }
    if (r.area === undefined) {
      r.area = r.type === 2 ? ['360px', '300px'] : '360px';
    }
    if (r.offset === undefined) {
      r.offset = '70px';
    }
    if (r.shade === undefined) {
      r.shade = 0.1;
    }
    if (r.fixed === undefined) {
      r.fixed = false;
    }
    if (r.resize === undefined) {
      r.resize = false;
    }
    if (r.skin === undefined) {
      r.skin = 'layui-layer-admin';
    }
    var p = r.end;
    r.end = function() {
      layuiLayer.closeAll('tips');
      p && p();
    };
    if (r.url) {
      var q = r.success;
      r.success = function(s, t) {
        $(s).data('tpl', r.tpl || '');
        admin.reloadLayer(t, r.url, q);
      };
    } else {
      if (r.tpl && r.content) {
        r.content = admin.util.tpl(r.content, r.data, layuiCache.tplOpen, layuiCache.tplClose);
      }
    }
    var i = layuiLayer.open(r);
    if (r.data) {
      admin.layerData['d' + i] = r.data;
    }
    return i;
  };
  admin.getLayerData = function(i, p) {
    if (i === undefined) {
      i = parent.layer.getFrameIndex(window.name);
      if (i === undefined) {
        return null;
      } else {
        return parent.layui.admin.getLayerData(parseInt(i), p);
      }
    } else {
      if (isNaN(i)) {
        i = admin.getLayerIndex(i);
      }
    }
    if (i === undefined) {
      return;
    }
    var q = admin.layerData['d' + i];
    if (p && q) {
      return q[p];
    }
    return q;
  };
  admin.putLayerData = function(p, r, i) {
    if (i === undefined) {
      i = parent.layer.getFrameIndex(window.name);
      if (i === undefined) {
        return;
      } else {
        return parent.layui.admin.putLayerData(p, r, parseInt(i));
      }
    } else {
      if (isNaN(i)) {
        i = admin.getLayerIndex(i);
      }
    }
    if (i === undefined) {
      return;
    }
    var q = admin.getLayerData(i);
    if (!q) {
      q = {};
    }
    q[p] = r;
    admin.layerData['d' + i] = q;
  };
  admin.reloadLayer = function(p, i, r) {
    if (typeof i === 'function') {
      r = i;
      i = undefined;
    }
    if (isNaN(p)) {
      p = admin.getLayerIndex(p);
    }
    if (p === undefined) {
      return;
    }
    var q = $('#layui-layer' + p);
    if (i === undefined) {
      i = q.data('url');
    }
    if (!i) {
      return;
    }
    q.data('url', i);
    admin.showLoading(q);
    admin.ajax({
      url     : i,
      dataType: 'html',
      success : function(v) {
        admin.removeLoading(q, false);
        if (typeof v !== 'string') {
          v = JSON.stringify(v);
        }
        var t = q.data('tpl');
        if (t === true || t === 'true') {
          var x = admin.getLayerData(p) || {};
          x.layerIndex = p;
          var s = $('<div>' + v + '</div>');
          var u = {};
          s.find('script,[tpl-ignore]').each(function(y) {
            var z = $(this);
            u['temp_' + y] = z[0].outerHTML;
            z.after('${temp_' + y + '}').remove();
          });
          v = admin.util.tpl(s.html(), x, layuiCache.tplOpen, layuiCache.tplClose);
          for (var w in u) {
            v = v.replace('${' + w + '}', u[w]);
          }
        }
        q.children('.layui-layer-content').html(v);
        admin.renderTpl('#layui-layer' + p + ' [ew-tpl]');
        r && r(q[0], p);
      }
    });
  };
  admin.alert = function(p, i, q) {
    if (typeof i === 'function') {
      q = i;
      i = {};
    }
    if (i.skin === undefined) {
      i.skin = 'layui-layer-admin';
    }
    if (i.shade === undefined) {
      i.shade = 0.1;
    }
    return layuiLayer.alert(p, i, q);
  };
  admin.confirm = function(q, i, r, p) {
    if (typeof i === 'function') {
      p = r;
      r = i;
      i = {};
    }
    if (i.skin === undefined) {
      i.skin = 'layui-layer-admin';
    }
    if (i.shade === undefined) {
      i.shade = 0.1;
    }
    return layuiLayer.confirm(q, i, r, p);
  };
  admin.prompt = function(i, p) {
    if (typeof i === 'function') {
      p = i;
      i = {};
    }
    if (i.skin === undefined) {
      i.skin = 'layui-layer-admin layui-layer-prompt';
    }
    if (i.shade === undefined) {
      i.shade = 0.1;
    }
    return layuiLayer.prompt(i, p);
  };
  admin.req = function(i, q, r, s, p) {
    if (typeof q === 'function') {
      p = s;
      s = r;
      r = q;
      q = {};
    }
    if (s !== undefined && typeof s !== 'string') {
      p = s;
      s = undefined;
    }
    if (!s) {
      s = 'GET';
    }
    if (typeof q === 'string') {
      if (!p) {
        p = {};
      }
      if (!p.contentType) {
        p.contentType = 'application/json;charset=UTF-8';
      }
    } else {
      if (layuiCache.reqPutToPost) {
        if (s.toLowerCase() === 'put') {
          s = 'POST';
          q._method = 'PUT';
        } else {
          if (s.toLowerCase() === 'delete') {
            s = 'GET';
            q._method = 'DELETE';
          }
        }
      }
    }
    return admin.ajax($.extend({
      url     : (layuiCache.baseServer || '') + i,
      data    : q,
      type    : s,
      dataType: 'json',
      success : r
    }, p));
  };
  admin.ajax = function(t) {
    var q = admin.util.deepClone(t);
    if (!t.dataType) {
      t.dataType = 'json';
    }
    if (!t.headers) {
      t.headers = {};
    }
    var s = layuiCache.getAjaxHeaders(t.url);
    if (s) {
      for (var p = 0; p < s.length; p++) {
        if (t.headers[s[p].name] === undefined) {
          t.headers[s[p].name] = s[p].value;
        }
      }
    }
    var r = t.success;
    t.success = function(i, u, w) {
      var v = layuiCache.ajaxSuccessBefore(admin.parseJSON(i), t.url, {
        param : q,
        reload: function(x) {
          admin.ajax($.extend(true, q, x));
        },
        update: function(x) {
          i = x;
        },
        xhr: w
      });
      if (v !== false) {
        r && r(i, u, w);
      } else {
        t.cancel && t.cancel();
      }
    };
    t.error = function(u, i) {
      t.success({
        code: u.status,
        msg : u.statusText
      }, i, u);
    };
    if (layui.cache.version && (!layuiCache.apiNoCache || t.dataType.toLowerCase() !== 'json')) {
      if (t.url.indexOf('?') === -1) {
        t.url += '?v=';
      } else {
        t.url += '&v=';
      }
      if (layui.cache.version === true) {
        t.url += new Date().getTime();
      } else {
        t.url += layui.cache.version;
      }
    }
    return $.ajax(t);
  };
  admin.parseJSON = function(p) {
    if (typeof p === 'string') {
      try {
        return JSON.parse(p);
      // eslint-disable-next-line no-empty
      } catch (i) {}
    }
    return p;
  };
  admin.showLoading = function(s, r, p, q) {
    if (s !== undefined && (typeof s !== 'string') && !(s instanceof $)) {
      r = s.type;
      p = s.opacity;
      q = s.size;
      s = s.elem;
    }
    if (r === undefined) {
      r = layuiCache.defaultLoading || 1;
    }
    if (q === undefined) {
      q = 'sm';
    }
    if (s === undefined) {
      s = 'body';
    }
    var i = ['<div class="ball-loader ' + q + '"><span></span><span></span><span></span><span></span></div>', '<div class="rubik-loader ' + q + '"></div>', '<div class="signal-loader ' + q + '"><span></span><span></span><span></span><span></span></div>', '<div class="layui-loader ' + q + '"><i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i></div>'];
    $(s).addClass('page-no-scroll');
    $(s).scrollTop(0);
    var t = $(s).children('.page-loading');
    if (t.length <= 0) {
      $(s).append('<div class="page-loading">' + i[r - 1] + '</div>');
      t = $(s).children('.page-loading');
    }
    if (p !== undefined) {
      t.css('background-color', 'rgba(255,255,255,' + p + ')');
    }
    t.show();
  };
  admin.removeLoading = function(p, r, i) {
    if (p === undefined) {
      p = 'body';
    }
    if (r === undefined) {
      r = true;
    }
    var q = $(p).children('.page-loading');
    if (i) {
      q.remove();
    } else {
      if (r) {
        q.fadeOut('fast');
      } else {
        q.hide();
      }
    }
    $(p).removeClass('page-no-scroll');
  };
  admin.putTempData = function(q, r, p) {
    var i = p ? layuiCache.tableName : layuiCache.tableName + '_tempData';
    if (r === undefined || r === null) {
      if (p) {
        layui.data(i, {
          key   : q,
          remove: true
        });
      } else {
        layui.sessionData(i, {
          key   : q,
          remove: true
        });
      }
    } else {
      if (p) {
        layui.data(i, {
          key  : q,
          value: r
        });
      } else {
        layui.sessionData(i, {
          key  : q,
          value: r
        });
      }
    }
  };
  admin.getTempData = function(q, p) {
    if (typeof q === 'boolean') {
      p = q;
      q = undefined;
    }
    var i = p ? layuiCache.tableName : layuiCache.tableName + '_tempData';
    var r = p ? layui.data(i) : layui.sessionData(i);
    if (!q) {
      return r;
    }
    return r ? r[q] : undefined;
  };
  admin.rollPage = function(r) {
    if (window !== top && !admin.isTop() && top.layui && top.layui.admin) {
      return top.layui.admin.rollPage(r);
    }
    var p = $(CLASS_TAB + '>.layui-tab-title');
    var q = p.scrollLeft();
    if (r === 'left') {
      p.animate({
        'scrollLeft': q - 120
      }, 100);
    } else {
      if (r === 'auto') {
        var i = 0;
        p.children('li').each(function() {
          if ($(this).hasClass('layui-this')) {
            return false;
          } else {
            i += $(this).outerWidth();
          }
        });
        p.animate({
          'scrollLeft': i - 120
        }, 100);
      } else {
        p.animate({
          'scrollLeft': q + 120
        }, 100);
      }
    }
  };
  admin.refresh = function(i, p) {
    if (window !== top && !admin.isTop() && top.layui && top.layui.admin) {
      return top.layui.admin.refresh(i);
    }
    var r;
    if (!i) {
      r = $(CLASS_TAB + '>.layui-tab-content>.layui-tab-item.layui-show>.admin-iframe');
      if (!r || r.length <= 0) {
        r = $(CLASS_BODY + '>div>.admin-iframe');
      }
    } else {
      r = $(CLASS_TAB + '>.layui-tab-content>.layui-tab-item>.admin-iframe[lay-id="' + i + '"]');
      if (!r || r.length <= 0) {
        r = $(CLASS_BODY + '>.admin-iframe');
      }
    }
    if (!r || !r[0]) {
      return console.warn(i + ' is not found');
    }
    try {
      if (p && r[0].contentWindow.refreshTab) {
        r[0].contentWindow.refreshTab();
      } else {
        admin.showLoading({
          elem: r.parent(),
          size: ''
        });
        r[0].contentWindow.location.reload();
      }
    } catch (q) {
      console.warn(q);
      r.attr('src', r.attr('src'));
    }
  };
  admin.closeThisTabs = function(i) {
    if (window !== top && !admin.isTop() && top.layui && top.layui.admin) {
      return top.layui.admin.closeThisTabs(i);
    }
    admin.closeTabOperNav();
    var p = $(CLASS_TAB + '>.layui-tab-title');
    if (!i) {
      if (p.find('li').first().hasClass('layui-this')) {
        return layuiLayer.msg('主页不能关闭', {
          icon: 2
        });
      }
      p.find('li.layui-this').find('.layui-tab-close').trigger('click');
    } else {
      if (i === p.find('li').first().attr('lay-id')) {
        return layuiLayer.msg('主页不能关闭', {
          icon: 2
        });
      }
      p.find('li[lay-id="' + i + '"]').find('.layui-tab-close').trigger('click');
    }
  };
  admin.closeOtherTabs = function(i) {
    if (window !== top && !admin.isTop() && top.layui && top.layui.admin) {
      return top.layui.admin.closeOtherTabs(i);
    }
    if (!i) {
      $(CLASS_TAB + '>.layui-tab-title li:gt(0):not(.layui-this)').find('.layui-tab-close').trigger('click');
    } else {
      $(CLASS_TAB + '>.layui-tab-title li:gt(0)').each(function() {
        if (i !== $(this).attr('lay-id')) {
          $(this).find('.layui-tab-close').trigger('click');
        }
      });
    }
    admin.closeTabOperNav();
  };
  admin.closeAllTabs = function() {
    if (window !== top && !admin.isTop() && top.layui && top.layui.admin) {
      return top.layui.admin.closeAllTabs();
    }
    $(CLASS_TAB + '>.layui-tab-title li:gt(0)').find('.layui-tab-close').trigger('click');
    $(CLASS_TAB + '>.layui-tab-title li:eq(0)').trigger('click');
    admin.closeTabOperNav();
  };
  admin.closeTabOperNav = function() {
    if (window !== top && !admin.isTop() && top.layui && top.layui.admin) {
      return top.layui.admin.closeTabOperNav();
    }
    $('.layui-icon-down .layui-nav .layui-nav-child').removeClass('layui-show');
  };
  admin.changeTheme = function(v, u, p, t) {
    if (!p) {
      admin.putSetting('defaultTheme', v);
    }
    if (!u) {
      u = top;
    }
    admin.removeTheme(u);
    if (v) {
      try {
        var r = u.layui.jquery('body');
        r.addClass(v);
        r.data('theme', v);
      } catch (s) {}
    }
    if (t) {
      return;
    }
    var w = u.frames;
    for (var q = 0; q < w.length; q++) {
      admin.changeTheme(v, w[q], true, false);
    }
  };
  admin.removeTheme = function(i) {
    if (!i) {
      i = window;
    }
    try {
      var p = i.layui.jquery('body');
      var r = p.data('theme');
      if (r) {
        p.removeClass(r);
      }
      p.removeData('theme');
    } catch (q) {}
  };
  admin.closeThisDialog = function() {
    return admin.closeDialog();
  };
  admin.closeDialog = function(i) {
    if (i) {
      layuiLayer.close(admin.getLayerIndex(i));
    } else {
      parent.layer.close(parent.layer.getFrameIndex(window.name));
    }
  };
  admin.getLayerIndex = function(i) {
    if (!i) {
      return parent.layer.getFrameIndex(window.name);
    }
    var p = $(i).parents('.layui-layer').first().attr('id');
    if (p && p.length >= 11) {
      return p.substring(11);
    }
  };
  admin.iframeAuto = function() {
    return parent.layer.iframeAuto(parent.layer.getFrameIndex(window.name));
  };
  admin.getPageHeight = function() {
    return document.documentElement.clientHeight || document.body.clientHeight;
  };
  admin.getPageWidth = function() {
    return document.documentElement.clientWidth || document.body.clientWidth;
  };
  admin.modelForm = function(p, s, i) {
    var r = $(p);
    r.addClass('layui-form');
    if (i) {
      r.attr('lay-filter', i);
    }
    var q = r.find('.layui-layer-btn .layui-layer-btn0');
    q.attr('lay-submit', '');
    q.attr('lay-filter', s);
  };
  admin.btnLoading = function(p, q, r) {
    if (q !== undefined && (typeof q === 'boolean')) {
      r = q;
      q = undefined;
    }
    if (q === undefined) {
      q = '&nbsp;加载中';
    }
    if (r === undefined) {
      r = true;
    }
    var i = $(p);
    if (r) {
      i.addClass('ew-btn-loading');
      i.prepend('<span class="ew-btn-loading-text"><i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>' + q + '</span>');
      i.attr('disabled', 'disabled').prop('disabled', true);
    } else {
      i.removeClass('ew-btn-loading');
      i.children('.ew-btn-loading-text').remove();
      i.removeProp('disabled').removeAttr('disabled');
    }
  };
  admin.openSideAutoExpand = function() {
    var i = $('.layui-layout-admin>.layui-side');
    i.off('mouseenter.openSideAutoExpand').on('mouseenter.openSideAutoExpand', function() {
      if (!$(this).parent().hasClass('admin-nav-mini')) {
        return;
      }
      admin.flexible(true);
      $(this).addClass('side-mini-hover');
    });
    i.off('mouseleave.openSideAutoExpand').on('mouseleave.openSideAutoExpand', function() {
      if (!$(this).hasClass('side-mini-hover')) {
        return;
      }
      admin.flexible(false);
      $(this).removeClass('side-mini-hover');
    });
  };
  admin.openCellAutoExpand = function() {
    var i = $('body');
    i.off('mouseenter.openCellAutoExpand').on('mouseenter.openCellAutoExpand', '.layui-table-view td', function() {
      $(this).find('.layui-table-grid-down').trigger('click');
    });
    i.off('mouseleave.openCellAutoExpand').on('mouseleave.openCellAutoExpand', '.layui-table-tips>.layui-layer-content', function() {
      $('.layui-table-tips-c').trigger('click');
    });
  };
  admin.parseLayerOption = function(q) {
    for (var r in q) {
      if (!q.hasOwnProperty(r)) {
        continue;
      }
      if (q[r] && q[r].toString().indexOf(',') !== -1) {
        q[r] = q[r].toString().split(',');
      }
    }
    var i = {
      'success': 'layero,index',
      'cancel' : 'index,layero',
      'end'    : '',
      'full'   : '',
      'min'    : '',
      'restore': ''
    };
    for (var p in i) {
      if (!i.hasOwnProperty(p) || !q[p]) {
        continue;
      }
      try {
        if (/^[a-zA-Z_]+[a-zA-Z0-9_]+$/.test(q[p])) {
          q[p] += '()';
        }
        q[p] = new Function(i[p], q[p]);
      } catch (s) {
        q[p] = undefined;
      }
    }
    if (q.content && (typeof q.content === 'string') && q.content.indexOf('#') === 0) {
      if ($(q.content).is('script')) {
        q.content = $(q.content).html();
      } else {
        q.content = $(q.content);
      }
    }
    if (q.type === undefined && q.url === undefined) {
      q.type = 2;
    }
    return q;
  };
  admin.strToWin = function(s) {
    var r = window;
    if (!s) {
      return r;
    }
    var p = s.split('.');
    for (var q = 0; q < p.length; q++) {
      r = r[p[q]];
    }
    return r;
  };
  admin.hideTableScrollBar = function(q) {
    if (admin.getPageWidth() <= 768) {
      return;
    }
    if (!q) {
      var p = $(CLASS_TAB + '>.layui-tab-content>.layui-tab-item.layui-show>.admin-iframe');
      if (p.length <= 0) {
        p = $(CLASS_BODY + '>div>.admin-iframe');
      }
      if (p.length > 0) {
        q = p[0].contentWindow;
      }
    }
    try {
      if (window.hsbTimer) {
        clearTimeout(window.hsbTimer);
      }
      q.layui.jquery('.layui-table-body.layui-table-main').addClass('no-scrollbar');
      window.hsbTimer = setTimeout(function() {
        q.layui.jquery('.layui-table-body.layui-table-main').removeClass('no-scrollbar');
      }, 800);
    } catch (i) {}
  };
  admin.isTop = function() {
    return $(CLASS_BODY).length > 0;
  };
  admin.events = {
    flexible: function() {
      admin.strToWin($(this).data('window')).layui.admin.flexible();
    },
    refresh: function() {
      admin.strToWin($(this).data('window')).layui.admin.refresh();
    },
    back: function() {
      admin.strToWin($(this).data('window')).history.back();
    },
    theme: function() {
      var i = admin.util.deepClone($(this).data());
      admin.strToWin(i.window).layui.admin.popupRight($.extend({
        id : 'layer-theme',
        url: i.url || 'page/tpl/tpl-theme.html'
      }, admin.parseLayerOption(i)));
    },
    note: function() {
      var i = admin.util.deepClone($(this).data());
      admin.strToWin(i.window).layui.admin.popupRight($.extend({
        id : 'layer-note',
        url: i.url || 'page/tpl/tpl-note.html'
      }, admin.parseLayerOption(i)));
    },
    message: function() {
      var i = admin.util.deepClone($(this).data());
      admin.strToWin(i.window).layui.admin.popupRight($.extend({
        id : 'layer-notice',
        url: i.url || 'page/tpl/tpl-message.html'
      }, admin.parseLayerOption(i)));
    },
    psw: function() {
      var i = admin.util.deepClone($(this).data());
      admin.strToWin(i.window).layui.admin.open($.extend({
        id   : 'layer-psw',
        title: '修改密码',
        shade: 0,
        url  : i.url || 'page/tpl/tpl-password.html'
      }, admin.parseLayerOption(i)));
    },
    logout: function() {
      var p = admin.util.deepClone($(this).data());
      admin.unlockScreen();

      function i() {
        if (p.ajax) {
          var q = layuiLayer.load(2);
          admin.req(p.ajax, function(s) {
            layuiLayer.close(q);
            if (p.parseData) {
              try {
                var r = new Function('res', p.parseData);
                s = r(s);
              } catch (t) {
                console.error(t);
              }
            }
            if (s.code == (p.code || 0)) {
              layuiCache.removeToken && layuiCache.removeToken();
              location.replace(p.url || '/');
            } else {
              layuiLayer.msg(s.msg, {
                icon: 2
              });
            }
          }, p.method || 'delete');
        } else {
          layuiCache.removeToken && layuiCache.removeToken();
          location.replace(p.url || '/');
        }
      }
      if (p.confirm === false || p.confirm === 'false') {
        return i();
      }
      admin.strToWin(p.window).layui.layer.confirm(p.content || '确定要退出登录吗？', $.extend({
        title: '温馨提示',
        skin : 'layui-layer-admin',
        shade: 0.1
      }, admin.parseLayerOption(p)), function() {
        i();
      });
    },
    open: function() {
      var i = admin.util.deepClone($(this).data());
      admin.strToWin(i.window).layui.admin.open(admin.parseLayerOption(i));
    },
    popupRight: function() {
      var i = admin.util.deepClone($(this).data());
      admin.strToWin(i.window).layui.admin.popupRight(admin.parseLayerOption(i));
    },
    fullScreen: function() {
      var w = 'layui-icon-screen-full';
      var p = 'layui-icon-screen-restore';
      var v = $(this).find('i');
      var s = document.fullscreenElement || document.msFullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || false;
      if (s) {
        var r = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen;
        if (r) {
          r.call(document);
        } else {
          if (window.ActiveXObject) {
            var t = new ActiveXObject('WScript.Shell');
            t && t.SendKeys('{F11}');
          }
        }
        v.addClass(w).removeClass(p);
      } else {
        var i = document.documentElement;
        var q = i.requestFullscreen || i.webkitRequestFullscreen || i.mozRequestFullScreen || i.msRequestFullscreen;
        if (q) {
          q.call(i);
        } else {
          if (window.ActiveXObject) {
            var u = new ActiveXObject('WScript.Shell');
            u && u.SendKeys('{F11}');
          }
        }
        v.addClass(p).removeClass(w);
      }
    },
    leftPage: function() {
      admin.strToWin($(this).data('window')).layui.admin.rollPage('left');
    },
    rightPage: function() {
      admin.strToWin($(this).data('window')).layui.admin.rollPage();
    },
    closeThisTabs: function() {
      var i = $(this).data('url');
      admin.strToWin($(this).data('window')).layui.admin.closeThisTabs(i);
    },
    closeOtherTabs: function() {
      admin.strToWin($(this).data('window')).layui.admin.closeOtherTabs();
    },
    closeAllTabs: function() {
      admin.strToWin($(this).data('window')).layui.admin.closeAllTabs();
    },
    closeDialog: function() {
      if ($(this).parents('.layui-layer').length > 0) {
        admin.closeDialog(this);
      } else {
        admin.closeDialog();
      }
    },
    closeIframeDialog: function() {
      admin.closeDialog();
    },
    closePageDialog: function() {
      admin.closeDialog(this);
    },
    lockScreen: function() {
      admin.strToWin($(this).data('window')).layui.admin.lockScreen($(this).data('url'));
    }
  };
  admin.chooseLocation = function(t) {
    var p = t.title;
    var x = t.onSelect;
    var r = t.needCity;
    var y = t.center;
    var B = t.defaultZoom;
    var u = t.pointZoom;
    var w = t.keywords;
    var A = t.pageSize;
    var s = t.mapJsUrl;
    if (p === undefined) {
      p = '选择位置';
    }
    if (B === undefined) {
      B = 11;
    }
    if (u === undefined) {
      u = 17;
    }
    if (w === undefined) {
      w = '';
    }
    if (A === undefined) {
      A = 30;
    }
    if (s === undefined) {
      s = 'https://webapi.amap.com/maps?v=1.4.14&key=006d995d433058322319fa797f2876f5';
    }
    var C = false;
    var z;
    var v = function(E, D) {
      AMap.service(['AMap.PlaceSearch'], function() {
        var G = new AMap.PlaceSearch({
          type     : '',
          pageSize : A,
          pageIndex: 1
        });
        var F = [D, E];
        G.searchNearBy(w, F, 1000, function(I, H) {
          if (I === 'complete') {
            var L = H.poiList.pois;
            var M = '';
            for (var K = 0; K < L.length; K++) {
              var J = L[K];
              if (J.location !== undefined) {
                M += '<div data-lng="' + J.location.lng + '" data-lat="' + J.location.lat + '" class="ew-map-select-search-list-item">';
                M += '     <div class="ew-map-select-search-list-item-title">' + J.name + '</div>';
                M += '     <div class="ew-map-select-search-list-item-address">' + J.address + '</div>';
                M += '     <div class="ew-map-select-search-list-item-icon-ok layui-hide"><i class="layui-icon layui-icon-ok-circle"></i></div>';
                M += '</div>';
              }
            }
            $('#ew-map-select-pois').html(M);
          }
        });
      });
    };
    var i = function() {
      var D = {
        resizeEnable: true,
        zoom        : B
      };
      y && (D.center = y);
      var F = new AMap.Map('ew-map-select-map', D);
      F.on('complete', function() {
        var G = F.getCenter();
        v(G.lat, G.lng);
      });
      F.on('moveend', function() {
        if (C) {
          C = false;
        } else {
          $('#ew-map-select-tips').addClass('layui-hide');
          $('#ew-map-select-center-img').removeClass('bounceInDown');
          setTimeout(function() {
            $('#ew-map-select-center-img').addClass('bounceInDown');
          });
          var G = F.getCenter();
          v(G.lat, G.lng);
        }
      });
      $('#ew-map-select-pois').off('click').on('click', '.ew-map-select-search-list-item', function() {
        $('#ew-map-select-tips').addClass('layui-hide');
        $('#ew-map-select-pois .ew-map-select-search-list-item-icon-ok').addClass('layui-hide');
        $(this).find('.ew-map-select-search-list-item-icon-ok').removeClass('layui-hide');
        $('#ew-map-select-center-img').removeClass('bounceInDown');
        setTimeout(function() {
          $('#ew-map-select-center-img').addClass('bounceInDown');
        });
        var I = $(this).data('lng');
        var J = $(this).data('lat');
        var H = $(this).find('.ew-map-select-search-list-item-title').text();
        var G = $(this).find('.ew-map-select-search-list-item-address').text();
        z = {
          name   : H,
          address: G,
          lat    : J,
          lng    : I
        };
        C = true;
        F.setZoomAndCenter(u, [I, J]);
      });
      $('#ew-map-select-btn-ok').click(function() {
        if (z === undefined) {
          layuiLayer.msg('请点击位置列表选择', {
            icon: 2,
            anim: 6
          });
        } else {
          if (x) {
            if (r) {
              var G = layuiLayer.load(2);
              F.setCenter([z.lng, z.lat]);
              F.getCity(function(H) {
                layuiLayer.close(G);
                z.city = H;
                admin.closeDialog('#ew-map-select-btn-ok');
                x(z);
              });
            } else {
              admin.closeDialog('#ew-map-select-btn-ok');
              x(z);
            }
          } else {
            admin.closeDialog('#ew-map-select-btn-ok');
          }
        }
      });
      var E = $('#ew-map-select-input-search');
      E.off('input').on('input', function() {
        var G = $(this).val();
        var H = $('#ew-map-select-tips');
        if (!G) {
          H.html('');
          H.addClass('layui-hide');
        }
        AMap.plugin('AMap.Autocomplete', function() {
          var I = new AMap.Autocomplete({
            city: '全国'
          });
          I.search(G, function(L, K) {
            if (K.tips) {
              var J = K.tips;
              var N = '';
              for (var M = 0; M < J.length; M++) {
                var O = J[M];
                if (O.location !== undefined) {
                  N += '<div data-lng="' + O.location.lng + '" data-lat="' + O.location.lat + '" class="ew-map-select-search-list-item">';
                  N += '     <div class="ew-map-select-search-list-item-icon-search"><i class="layui-icon layui-icon-search"></i></div>';
                  N += '     <div class="ew-map-select-search-list-item-title">' + O.name + '</div>';
                  N += '     <div class="ew-map-select-search-list-item-address">' + O.address + '</div>';
                  N += '</div>';
                }
              }
              H.html(N);
              if (J.length === 0) {
                $('#ew-map-select-tips').addClass('layui-hide');
              } else {
                $('#ew-map-select-tips').removeClass('layui-hide');
              }
            } else {
              H.html('');
              H.addClass('layui-hide');
            }
          });
        });
      });
      E.off('blur').on('blur', function() {
        var G = $(this).val();
        var H = $('#ew-map-select-tips');
        if (!G) {
          H.html('');
          H.addClass('layui-hide');
        }
      });
      E.off('focus').on('focus', function() {
        var G = $(this).val();
        if (G) {
          $('#ew-map-select-tips').removeClass('layui-hide');
        }
      });
      $('#ew-map-select-tips').off('click').on('click', '.ew-map-select-search-list-item', function() {
        $('#ew-map-select-tips').addClass('layui-hide');
        var G = $(this).data('lng');
        var H = $(this).data('lat');
        z = undefined;
        F.setZoomAndCenter(u, [G, H]);
      });
    };
    var q = ['<div class="ew-map-select-tool" style="position: relative;">', '     搜索：<input id="ew-map-select-input-search" class="layui-input icon-search inline-block" style="width: 190px;" placeholder="输入关键字搜索" autocomplete="off" />', '     <button id="ew-map-select-btn-ok" class="layui-btn icon-btn pull-right" type="button"><i class="layui-icon">&#xe605;</i>确定</button>', '     <div id="ew-map-select-tips" class="ew-map-select-search-list layui-hide">', '     </div>', '</div>', '<div class="layui-row ew-map-select">', '     <div class="layui-col-sm7 ew-map-select-map-group" style="position: relative;">', '          <div id="ew-map-select-map"></div>', '          <i id="ew-map-select-center-img2" class="layui-icon layui-icon-add-1"></i>', '          <img id="ew-map-select-center-img" src="https://3gimg.qq.com/lightmap/components/locationPicker2/image/marker.png" alt=""/>', '     </div>', '     <div id="ew-map-select-pois" class="layui-col-sm5 ew-map-select-search-list">', '     </div>', '</div>'].join('');
    admin.open({
      id     : 'ew-map-select',
      type   : 1,
      title  : p,
      area   : '750px',
      content: q,
      success: function(D, F) {
        var E = $(D).children('.layui-layer-content');
        E.css('overflow', 'visible');
        admin.showLoading(E);
        if (undefined === window.AMap) {
          $.getScript(s, function() {
            i();
            admin.removeLoading(E);
          });
        } else {
          i();
          admin.removeLoading(E);
        }
      }
    });
  };
  admin.cropImg = function(r) {
    var p = 'image/jpeg';
    var w = r.aspectRatio;
    var x = r.imgSrc;
    var u = r.imgType;
    var s = r.onCrop;
    var t = r.limitSize;
    var v = r.acceptMime;
    var q = r.exts;
    var i = r.title;
    if (w === undefined) {
      w = 1;
    }
    if (i === undefined) {
      i = '裁剪图片';
    }
    if (u) {
      p = u;
    }
    layui.use(['Cropper', 'upload'], function() {
      var z = layui.Cropper;
      var y = layui.upload;

      function A() {
        var D; var E = $('#ew-crop-img');
        var F = {
          elem  : '#ew-crop-img-upload',
          auto  : false,
          drag  : false,
          choose: function(G) {
            G.preview(function(I, J, H) {
              p = J.type;
              E.attr('src', H);
              if (!x || !D) {
                x = H;
                A();
              } else {
                D.destroy();
                D = new z(E[0], C);
              }
            });
          }
        };
        if (t !== undefined) {
          F.size = t;
        }
        if (v !== undefined) {
          F.acceptMime = v;
        }
        if (q !== undefined) {
          F.exts = q;
        }
        y.render(F);
        if (!x) {
          return $('#ew-crop-img-upload').trigger('click');
        }
        var C = {
          aspectRatio: w,
          preview    : '#ew-crop-img-preview'
        };
        D = new z(E[0], C);
        $('.ew-crop-tool').on('click', '[data-method]', function() {
          var H = $(this).data();
          var I; var G;
          if (!D || !H.method) {
            return;
          }
          H = $.extend({}, H);
          I = D.cropped;
          switch (H.method) {
            case 'rotate':
              if (I && C.viewMode > 0) {
                D.clear();
              }
              break;
            case 'getCroppedCanvas':
              if (p === 'image/jpeg') {
                if (!H.option) {
                  H.option = {};
                }
                H.option.fillColor = '#fff';
              }
              break;
          }
          G = D[H.method](H.option, H.secondOption);
          switch (H.method) {
            case 'rotate':
              if (I && C.viewMode > 0) {
                D.crop();
              }
              break;
            case 'scaleX':
            case 'scaleY':
              $(this).data('option', -H.option);
              break;
            case 'getCroppedCanvas':
              if (G) {
                s && s(G.toDataURL(p));
                admin.closeDialog('#ew-crop-img');
              } else {
                layuiLayer.msg('裁剪失败', {
                  icon: 2,
                  anim: 6
                });
              }
              break;
          }
        });
      }
      var B = ['<div class="layui-row">', '     <div class="layui-col-sm8" style="min-height: 9rem;">', '          <img id="ew-crop-img" src="', x || '', '" style="max-width:100%;" alt=""/>', '     </div>', '     <div class="layui-col-sm4 layui-hide-xs" style="padding: 15px;text-align: center;">', '          <div id="ew-crop-img-preview" style="width: 100%;height: 9rem;overflow: hidden;display: inline-block;border: 1px solid #dddddd;"></div>', '     </div>', '</div>', '<div class="text-center ew-crop-tool" style="padding: 15px 10px 5px 0;">', '     <div class="layui-btn-group" style="margin-bottom: 10px;margin-left: 10px;">', '          <button title="放大" data-method="zoom" data-option="0.1" class="layui-btn icon-btn" type="button"><i class="layui-icon layui-icon-add-1"></i></button>', '          <button title="缩小" data-method="zoom" data-option="-0.1" class="layui-btn icon-btn" type="button"><span style="display: inline-block;width: 12px;height: 2.5px;background: rgba(255, 255, 255, 0.9);vertical-align: middle;margin: 0 4px;"></span></button>', '     </div>', '     <div class="layui-btn-group layui-hide-xs" style="margin-bottom: 10px;">', '          <button title="向左旋转" data-method="rotate" data-option="-45" class="layui-btn icon-btn" type="button"><i class="layui-icon layui-icon-refresh-1" style="transform: rotateY(180deg) rotate(40deg);display: inline-block;"></i></button>', '          <button title="向右旋转" data-method="rotate" data-option="45" class="layui-btn icon-btn" type="button"><i class="layui-icon layui-icon-refresh-1" style="transform: rotate(30deg);display: inline-block;"></i></button>', '     </div>', '     <div class="layui-btn-group" style="margin-bottom: 10px;">', '          <button title="左移" data-method="move" data-option="-10" data-second-option="0" class="layui-btn icon-btn" type="button"><i class="layui-icon layui-icon-left"></i></button>', '          <button title="右移" data-method="move" data-option="10" data-second-option="0" class="layui-btn icon-btn" type="button"><i class="layui-icon layui-icon-right"></i></button>', '          <button title="上移" data-method="move" data-option="0" data-second-option="-10" class="layui-btn icon-btn" type="button"><i class="layui-icon layui-icon-up"></i></button>', '          <button title="下移" data-method="move" data-option="0" data-second-option="10" class="layui-btn icon-btn" type="button"><i class="layui-icon layui-icon-down"></i></button>', '     </div>', '     <div class="layui-btn-group" style="margin-bottom: 10px;">', '          <button title="左右翻转" data-method="scaleX" data-option="-1" class="layui-btn icon-btn" type="button" style="position: relative;width: 41px;"><i class="layui-icon layui-icon-triangle-r" style="position: absolute;left: 9px;top: 0;transform: rotateY(180deg);font-size: 16px;"></i><i class="layui-icon layui-icon-triangle-r" style="position: absolute; right: 3px; top: 0;font-size: 16px;"></i></button>', '          <button title="上下翻转" data-method="scaleY" data-option="-1" class="layui-btn icon-btn" type="button" style="position: relative;width: 41px;"><i class="layui-icon layui-icon-triangle-d" style="position: absolute;left: 11px;top: 6px;transform: rotateX(180deg);line-height: normal;font-size: 16px;"></i><i class="layui-icon layui-icon-triangle-d" style="position: absolute; left: 11px; top: 14px;line-height: normal;font-size: 16px;"></i></button>', '     </div>', '     <div class="layui-btn-group" style="margin-bottom: 10px;">', '          <button title="重新开始" data-method="reset" class="layui-btn icon-btn" type="button"><i class="layui-icon layui-icon-refresh"></i></button>', '          <button title="选择图片" id="ew-crop-img-upload" class="layui-btn icon-btn" type="button" style="border-radius: 0 2px 2px 0;"><i class="layui-icon layui-icon-upload-drag"></i></button>', '     </div>', '     <button data-method="getCroppedCanvas" data-option="{ &quot;maxWidth&quot;: 4096, &quot;maxHeight&quot;: 4096 }" class="layui-btn icon-btn" type="button" style="margin-left: 10px;margin-bottom: 10px;"><i class="layui-icon">&#xe605;</i>完成</button>', '</div>'].join('');
      admin.open({
        title  : i,
        area   : '665px',
        type   : 1,
        content: B,
        success: function(C, D) {
          $(C).children('.layui-layer-content').css('overflow', 'visible');
          A();
        }
      });
    });
  };
  admin.util = {
    Convert_BD09_To_GCJ02: function(p) {
      var r = (3.141592653589793 * 3000) / 180;
      var i = p.lng - 0.0065;
      var t = p.lat - 0.006;
      var s = Math.sqrt(i * i + t * t) - 0.00002 * Math.sin(t * r);
      var q = Math.atan2(t, i) - 0.000003 * Math.cos(i * r);
      return {
        lng: s * Math.cos(q),
        lat: s * Math.sin(q)
      };
    },
    Convert_GCJ02_To_BD09: function(p) {
      var r = (3.141592653589793 * 3000) / 180;
      var i = p.lng;
      var t = p.lat;
      var s = Math.sqrt(i * i + t * t) + 0.00002 * Math.sin(t * r);
      var q = Math.atan2(t, i) + 0.000003 * Math.cos(i * r);
      return {
        lng: s * Math.cos(q) + 0.0065,
        lat: s * Math.sin(q) + 0.006
      };
    },
    animateNum: function(t, p, r, u) {
      p = p === null || p === undefined || p === true || p === 'true';
      r = isNaN(r) ? 500 : r;
      u = isNaN(u) ? 100 : u;
      var s = function(x) {
        var v = '';
        for (var w = 0; w < x.length; w++) {
          if (!isNaN(x.charAt(w))) {
            return v;
          } else {
            v += x.charAt(w);
          }
        }
      };
      var i = function(x) {
        var v = '';
        for (var w = x.length - 1; w >= 0; w--) {
          if (!isNaN(x.charAt(w))) {
            return v;
          } else {
            v = x.charAt(w) + v;
          }
        }
      };
      var q = function(w, v) {
        if (!v) {
          return w;
        }
        if (!/^[0-9]+.?[0-9]*$/.test(w)) {
          return w;
        }
        w = w.toString();
        return w.replace(w.indexOf('.') > 0 ? /(\d)(?=(\d{3})+(?:\.))/g : /(\d)(?=(\d{3})+(?:$))/g, '$1,');
      };
      $(t).each(function() {
        var B = $(this);
        var y = B.data('num');
        if (!y) {
          y = B.text().replace(/,/g, '');
          B.data('num', y);
        }
        var A = 'INPUT,TEXTAREA'.indexOf(B.get(0).tagName) >= 0;
        var H = s(y.toString());
        var E = i(y.toString());
        var G = y.toString().replace(H, '').replace(E, '');
        if (isNaN(G * 1) || G === '0') {
          A ? B.val(y) : B.html(y);
          return console.error('not a number');
        }
        var v = G.split('.');
        var C = v[1] ? v[1].length : 0;
        var x = 0;
        var D = G;
        if (Math.abs(D * 1) > 10) {
          x = parseFloat(v[0].substring(0, v[0].length - 1) + (v[1] ? '.0' + v[1] : ''));
        }
        var z = (D - x) / u;
        var F = 0;
        var w = setInterval(function() {
          var I = H + q(x.toFixed(C), p) + E;
          A ? B.val(I) : B.html(I);
          x += z;
          F++;
          if (Math.abs(x) >= Math.abs(D * 1) || F > 5000) {
            I = H + q(D, p) + E;
            A ? B.val(I) : B.html(I);
            clearInterval(w);
          }
        }, r / u);
      });
    },
    deepClone: function(s) {
      var i;
      var p = admin.util.isClass(s);
      if (p === 'Object') {
        i = {};
      } else {
        if (p === 'Array') {
          i = [];
        } else {
          return s;
        }
      }
      for (var r in s) {
        if (!s.hasOwnProperty(r)) {
          continue;
        }
        var t = s[r];
        var q = admin.util.isClass(t);
        if (q === 'Object') {
          i[r] = arguments.callee(t);
        } else {
          if (q === 'Array') {
            i[r] = arguments.callee(t);
          } else {
            i[r] = s[r];
          }
        }
      }
      return i;
    },
    isClass: function(i) {
      if (i === null) {
        return 'Null';
      }
      if (i === undefined) {
        return 'Undefined';
      }
      return Object.prototype.toString.call(i).slice(8, -1);
    },
    fullTextIsEmpty: function(s) {
      if (!s) {
        return true;
      }
      var q = ['img', 'audio', 'video', 'iframe', 'object'];
      for (var p = 0; p < q.length; p++) {
        if (s.indexOf('<' + q[p]) > -1) {
          return false;
        }
      }
      var r = s.replace(/\s*/g, '');
      if (!r) {
        return true;
      }
      r = r.replace(/&nbsp;/ig, '');
      if (!r) {
        return true;
      }
      r = r.replace(/<[^>]+>/g, '');
      return !r;
    },
    removeStyle: function(q, r) {
      if (typeof r === 'string') {
        r = [r];
      }
      for (var p = 0; p < r.length; p++) {
        $(q).css(r[p], '');
      }
    },
    scrollTop: function(i) {
      $(i || 'html,body').animate({
        scrollTop: 0
      }, 300);
    },
    tpl: function(q, r, i, s) {
      if (q === undefined || q === null || typeof q !== 'string') {
        return q;
      }
      if (!r) {
        r = {};
      }
      if (!i) {
        i = '{{';
      }
      if (!s) {
        s = '}}';
      }
      var p = {
        exp: function(t) {
          return new RegExp(t, 'g');
        },
        query: function(v, t, w) {
          var u = ['#([\\s\\S])+?', '([^{#}])*?'][v || 0];
          return p.exp((t || '') + i + u + s + (w || ''));
        },
        escape: function(t) {
          return String(t || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/'/g, '&#39;').replace(/"/g, '&quot;');
        },
        error: function(u, t) {
          console.error('Laytpl Error：' + u + '\n' + (t || ''));
        },
        parse: function(u, v) {
          var t = u;
          try {
            var x = p.exp('^' + i + '#');
            var y = p.exp(s + '$');
            u = u.replace(p.exp(i + '#'), i + '# ').replace(p.exp(s + '}'), '} ' + s).replace(/\\/g, '\\\\').replace(p.exp(i + '!(.+?)!' + s), function(z) {
              z = z.replace(p.exp('^' + i + '!'), '').replace(p.exp('!' + s), '').replace(p.exp(i + '|' + s), function(A) {
                return A.replace(/(.)/g, '\\$1');
              });
              return z;
            }).replace(/(?="|')/g, '\\').replace(p.query(), function(z) {
              z = z.replace(x, '').replace(y, '');
              return '";' + z.replace(/\\/g, '') + ';view+="';
            }).replace(p.query(1), function(z) {
              var A = '"+(';
              if (z.replace(/\s/g, '') === i + s) {
                return '';
              }
              z = z.replace(p.exp(i + '|' + s), '');
              if (/^=/.test(z)) {
                z = z.replace(/^=/, '');
                A = '"+_escape_(';
              }
              return A + z.replace(/\\/g, '') + ')+"';
            }).replace(/\r\n/g, '\\r\\n" + "').replace(/\n/g, '\\n" + "').replace(/\r/g, '\\r" + "');
            u = '"use strict";var view = "' + u + '";return view;';
            u = new Function('d, _escape_', u);
            return u(v, p.escape);
          } catch (w) {
            p.error(w, t);
            return t;
          }
        }
      };
      return p.parse(q, r);
    },
    render: function(p) {
      if (typeof p.url === 'string') {
        p.success = function(q) {
          admin.util.render($.extend({}, p, {
            url: q
          }));
        };
        if (p.ajax === 'ajax') {
          admin.ajax(p);
        } else {
          admin.req(p.url, p.where, p.success, p.method, p);
        }
        return;
      }
      var i = admin.util.tpl(p.tpl, p.url, p.open || layuiCache.tplOpen, p.close || layuiCache.tplClose);
      $(p.elem).next('[ew-tpl-rs]').remove();
      $(p.elem).after(i);
      $(p.elem).next().attr('ew-tpl-rs', '');
      p.done && p.done(p.url);
    }
  };
  admin.lockScreen = function(q) {
    if (window !== top && !admin.isTop() && top.layui && top.layui.admin) {
      return top.layui.admin.lockScreen(q);
    }
    if (!q) {
      q = 'page/tpl/tpl-lock-screen.html';
    }
    var i = $('#ew-lock-screen-group');
    if (i.length > 0) {
      i.fadeIn('fast');
      admin.isLockScreen = true;
      admin.putTempData('isLockScreen', admin.isLockScreen, true);
    } else {
      var p = layuiLayer.load(2);
      admin.ajax({
        url     : q,
        dataType: 'html',
        success : function(r) {
          layuiLayer.close(p);
          if (typeof r === 'string') {
            $('body').append('<div id="ew-lock-screen-group">' + r + '</div>');
            admin.isLockScreen = true;
            admin.putTempData('isLockScreen', admin.isLockScreen, true);
            admin.putTempData('lockScreenUrl', q, true);
          } else {
            console.error(r);
            layuiLayer.msg(JSON.stringify(r), {
              icon: 2,
              anim: 6
            });
          }
        }
      });
    }
  };
  admin.unlockScreen = function(p) {
    if (window !== top && !admin.isTop() && top.layui && top.layui.admin) {
      return top.layui.admin.unlockScreen(p);
    }
    var i = $('#ew-lock-screen-group');
    p ? i.remove() : i.fadeOut('fast');
    admin.isLockScreen = false;
    admin.putTempData('isLockScreen', null, true);
  };
  admin.tips = function(i) {
    return layuiLayer.tips(i.text, i.elem, {
      tips    : [i.direction || 1, i.bg || '#191a23'],
      tipsMore: i.tipsMore,
      time    : i.time || -1,
      success : function(p) {
        var q = $(p).children('.layui-layer-content');
        if (i.padding || i.padding === 0) {
          q.css('padding', i.padding);
        }
        if (i.color) {
          q.css('color', i.color);
        }
        if (i.bgImg) {
          q.css('background-image', i.bgImg).children('.layui-layer-TipsG').css('z-index', '-1');
        }
        if (i.fontSize) {
          q.css('font-size', i.fontSize);
        }
        if (!i.offset) {
          return;
        }
        var t = i.offset.split(',');
        var s = t[0];
        var r = t.length > 1 ? t[1] : undefined;
        if (s) {
          $(p).css('margin-top', s);
        }
        if (r) {
          $(p).css('margin-left', r);
        }
      }
    });
  };
  admin.renderTpl = function(p) {
    if (!layui.admin) {
      layui.admin = admin;
    }

    function i(q) {
      if (!q) {
        return;
      }
      try {
        return new Function('return ' + q + ';')();
      } catch (r) {
        console.error(r + '\nlay-data: ' + q);
      }
    }
    $(p || '[ew-tpl]').each(function() {
      var s = $(this);
      var q = $(this).data();
      q.elem = s;
      q.tpl = s.html();
      q.url = i(s.attr('ew-tpl'));
      q.headers = i(q.headers);
      q.where = i(q.where);
      if (q.done) {
        try {
          q.done = new Function('res', q.done);
        } catch (r) {
          console.error(r + '\nlay-data:' + q.done);
          q.done = undefined;
        }
      }
      admin.util.render(q);
    });
  };
  admin.on = function(i, p) {
    return layui.onevent.call(this, 'admin', i, p);
  };
  admin.putSetting = function(i, p) {
    layuiCache[i] = p;
    admin.putTempData(i, p, true);
  };
  admin.recoverState = function() {
    if (admin.getTempData('isLockScreen', true)) {
      admin.lockScreen(admin.getTempData('lockScreenUrl', true));
    }
    if (layuiCache.defaultTheme) {
      admin.changeTheme(layuiCache.defaultTheme, window, true, true);
    }
    if (layuiCache.closeFooter) {
      $('body').addClass('close-footer');
    }
    if (layuiCache.navArrow !== undefined) {
      var i = $(CLASS_SIDE_SCROLL + '>.layui-nav-tree');
      i.removeClass('arrow2 arrow3');
      if (layuiCache.navArrow) {
        i.addClass(layuiCache.navArrow);
      }
    }
    if (layuiCache.pageTabs && layuiCache.tabAutoRefresh == 'true') {
      $(CLASS_TAB).attr('lay-autoRefresh', 'true');
    }
  };
  admin.on = function(i, p) {
    return layui.onevent.call(this, 'admin', i, p);
  };
  var m = '.layui-layout-admin.admin-nav-mini>.layui-side .layui-nav .layui-nav-item';
  $(document).on('mouseenter', m + ',' + m + ' .layui-nav-child>dd', function() {
    if (admin.getPageWidth() > 768) {
      var i = $(this);
      var q = i.find('>.layui-nav-child');
      if (q.length > 0) {
        i.addClass('admin-nav-hover');
        q.css('left', i.offset().left + i.outerWidth());
        var p = i.offset().top;
        if (p + q.outerHeight() > admin.getPageHeight()) {
          p = p - q.outerHeight() + i.outerHeight();
          if (p < 60) {
            p = 60;
          }
          q.addClass('show-top');
        }
        q.css('top', p);
        q.addClass('ew-anim-drop-in');
      } else {
        if (i.hasClass('layui-nav-item')) {
          admin.tips({
            elem     : i,
            text     : i.find('cite').text(),
            direction: 2,
            offset   : '12px'
          });
        }
      }
    }
  }).on('mouseleave', m + ',' + m + ' .layui-nav-child>dd', function() {
    layuiLayer.closeAll('tips');
    var p = $(this);
    p.removeClass('admin-nav-hover');
    var i = p.find('>.layui-nav-child');
    i.removeClass('show-top ew-anim-drop-in');
    i.css({
      'left': 'auto',
      'top' : 'auto'
    });
  });
  $(document).on('click', '*[ew-event]', function() {
    var i = admin.events[$(this).attr('ew-event')];
    i && i.call(this, $(this));
  });
  $(document).on('mouseenter', '*[lay-tips]', function() {
    var i = $(this);
    admin.tips({
      elem     : i,
      text     : i.attr('lay-tips'),
      direction: i.attr('lay-direction'),
      bg       : i.attr('lay-bg'),
      offset   : i.attr('lay-offset'),
      padding  : i.attr('lay-padding'),
      color    : i.attr('lay-color'),
      bgImg    : i.attr('lay-bgImg'),
      fontSize : i.attr('lay-fontSize')
    });
  }).on('mouseleave', '*[lay-tips]', function() {
    layuiLayer.closeAll('tips');
  });
  $(document).on('click', '.form-search-expand,[search-expand]', function() {
    var r = $(this);
    var p = r.parents('.layui-form').first();
    var q = r.data('expand');
    var s = r.attr('search-expand');
    if (q === undefined || q === true) {
      q = true;
      r.data('expand', false);
      r.html('收起 <i class="layui-icon layui-icon-up"></i>');
      var i = p.find('.form-search-show-expand');
      i.attr('expand-show', '');
      i.removeClass('form-search-show-expand');
    } else {
      q = false;
      r.data('expand', true);
      r.html('展开 <i class="layui-icon layui-icon-down"></i>');
      p.find('[expand-show]').addClass('form-search-show-expand');
    }
    if (!s) {
      return;
    }
    new Function('d', s)({
      expand: q,
      elem  : r
    });
  });
  $(document).on('click.ew-sel-fixed', '.ew-select-fixed .layui-form-select .layui-select-title', function() {
    var v = $(this);
    var r = v.parent().children('dl');
    var t = v.offset().top;
    var s = v.outerWidth();
    var x = v.outerHeight();
    var i = $(document).scrollTop();
    var u = r.outerWidth();
    var q = r.outerHeight();
    var w = t + x + 5 - i;
    var p = v.offset().left;
    if (w + q > admin.getPageHeight()) {
      w = w - q - x - 10;
    }
    if (p + u > admin.getPageWidth()) {
      p = p - u + s;
    }
    r.css({
      'left'     : p,
      'top'      : w,
      'min-width': s
    });
  });
  admin.hideFixedEl = function() {
    $('.ew-select-fixed .layui-form-select').removeClass('layui-form-selected layui-form-selectup');
    $('body>.layui-laydate').remove();
  };
  $(document).on('click', '.layui-nav-tree>.layui-nav-item a', function() {
    var r = $(this);
    var p = r.siblings('.layui-nav-child');
    var q = r.parent();
    if (p.length === 0) {
      return;
    }
    if (q.hasClass('admin-nav-hover')) {
      return;
    }
    if (q.hasClass('layui-nav-itemed')) {
      p.css('display', 'none').slideDown('fast', function() {
        $(this).css('display', '');
      });
    } else {
      p.css('display', 'block').slideUp('fast', function() {
        $(this).css('display', '');
      });
    }
    if (r.parents('.layui-nav').attr('lay-shrink') === '_all') {
      var i = r.parent().siblings('.layui-nav-itemed');
      i.children('.layui-nav-child').css('display', 'block').slideUp('fast', function() {
        $(this).css('display', '');
      });
      i.removeClass('layui-nav-itemed');
    }
  });
  $('.layui-nav-tree[lay-shrink="all"]').attr('lay-shrink', '_all');
  $(document).on('click', '.layui-collapse>.layui-colla-item>.layui-colla-title', function() {
    var s = $(this);
    var i = s.siblings('.layui-colla-content');
    var q = s.parent().parent();
    var p = i.hasClass('layui-show');
    if (p) {
      i.removeClass('layui-show').slideDown('fast').addClass('layui-show');
    } else {
      i.css('display', 'block').slideUp('fast', function() {
        $(this).css('display', '');
      });
    }
    s.children('.layui-colla-icon').html('&#xe602;').css({
      'transition': 'all .3s',
      'transform' : 'rotate(' + (p ? '90deg' : '0deg') + ')'
    });
    if (q.attr('lay-shrink') === '_all') {
      var r = q.children('.layui-colla-item').children('.layui-colla-content.layui-show').not(i);
      r.css('display', 'block').slideUp('fast', function() {
        $(this).css('display', '');
      });
      r.removeClass('layui-show');
      r.siblings('.layui-colla-title').children('.layui-colla-icon').html('&#xe602;').css({
        'transition': 'all .3s',
        'transform' : 'rotate(0deg)'
      });
    }
  });
  $('.layui-collapse[lay-accordion]').attr('lay-shrink', '_all').removeAttr('lay-accordion');
  layuiLayer.oldTips = layuiLayer.tips;
  layuiLayer.tips = function(r, i, q) {
    var p;
    if ($(i).length > 0 && $(i).parents('.layui-form').length > 0) {
      if ($(i).is('input') || $(i).is('textarea')) {
        p = $(i);
      } else {
        if ($(i).hasClass('layui-form-select') || $(i).hasClass('layui-form-radio') || $(i).hasClass('layui-form-checkbox') || $(i).hasClass('layui-form-switch')) {
          p = $(i).prev();
        }
      }
    }
    if (!p) {
      return layuiLayer.oldTips(r, i, q);
    }
    q.tips = [p.attr('lay-direction') || 3, p.attr('lay-bg') || '#ff4c4c'];
    setTimeout(function() {
      q.success = function(s) {
        $(s).children('.layui-layer-content').css('padding', '6px 12px');
      };
      layuiLayer.oldTips(r, i, q);
    }, 100);
  };
  $(document).on('click', '*[ew-href]', function() {
    var s = $(this);
    var p = s.attr('ew-href');
    if (!p || p === '#') {
      return;
    }
    if (p.indexOf('javascript:') === 0) {
      return new Function(p.substring(11))();
    }
    var t = s.attr('ew-title') || s.text();
    var r = s.data('window');
    r ? (r = admin.strToWin(r)) : (r = top);
    var i = s.attr('ew-end');
    try {
      if (i) {
        i = new Function(i);
      } else {
        i = undefined;
      }
    } catch (q) {
      console.error(q);
    }
    if (r.layui && r.layui.index) {
      r.layui.index.openTab({
        title: t || '',
        url  : p,
        end  : i
      });
    } else {
      location.href = p;
    }
  });
  if (!layui.contextMenu) {
    $(document).off('click.ctxMenu').on('click.ctxMenu', function() {
      try {
        var s = top.window.frames;
        for (var p = 0; p < s.length; p++) {
          var q = s[p];
          try {
            if (q.layui && q.layui.jquery) {
              q.layui.jquery('body>.ctxMenu').remove();
            }
          } catch (r) {}
        }
        try {
          if (top.layui && top.layui.jquery) {
            top.layui.jquery('body>.ctxMenu').remove();
          }
        } catch (r) {}
      } catch (r) {}
    });
  }
  layuiCache = $.extend({
    pageTabs         : true,
    cacheTab         : true,
    openTabCtxMenu   : true,
    maxTabNum        : 20,
    tableName        : 'easyweb-iframe',
    apiNoCache       : true,
    ajaxSuccessBefore: function(p, i, q) {
      return admin.ajaxSuccessBefore ? admin.ajaxSuccessBefore(p, i, q) : true;
    },
    getAjaxHeaders: function(p, i, q) {
      return admin.getAjaxHeaders ? admin.getAjaxHeaders(p, i, q) : [];
    }
  }, layuiCache);
  var a = admin.getTempData(true);
  if (a) {
    var o = ['pageTabs', 'cacheTab', 'defaultTheme', 'navArrow', 'closeFooter', 'tabAutoRefresh'];
    for (var g = 0; g < o.length; g++) {
      if (a[o[g]] !== undefined) {
        layuiCache[o[g]] = a[o[g]];
      }
    }
  }
  admin.recoverState();
  admin.renderTpl();
  admin.setter = layuiCache;
  if (layui.device().ios) {
    $('body').addClass('ios-iframe-body');
  }
  f('admin', admin);
});
